package databaseVersionControl.test;

import junit.framework.Assert;

import org.junit.Test;

import databaseVersionControl.domain.db.Column;
import databaseVersionControl.domain.db.DataType;
import databaseVersionControl.domain.factory.composite.CreateTableComposite;
import databaseVersionControl.infra.connection.DataBaseProxy;
import databaseVersionControl.infra.script.Repository;
import databaseVersionControl.infra.script.Script;
import databaseVersionControl.infra.script.ScriptRegister;

public class CreateObjects extends TestHarness {

	@Test
	public void creatTableIfNotExists() {

		CreateTableComposite createTable = new Script().create().table("E").ifNotExists().defineColumns(
				new Column("ID").primaryKey().notNull().type(DataType.LONG));
		
		ScriptRegister.register(new TestScriptKey("E", 1), createTable);
		
		ScriptRegister.register(new TestScriptKey("E", 2), createTable);
		
		Repository.getInstance().install();
		
		Assert.assertEquals(true, DataBaseProxy.existsTable(createTable.getName()));

	}

}
